package com.payment_server.util;

import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Component;
import redis.clients.jedis.Jedis;

@Component
public class TokenUtil {

    private static Jedis redis;

    static {
        redis = RedisUtil.getRedisDS();
    }

    /**
     * 获取token信息
     * @param token
     * @return null/JSONObject
     */
    public static JSONObject getTokenInfo(String token){
        if(!redis.exists(token)) return new JSONObject();
        return JSONObject.parseObject(redis.get(token));
    }
}
